/*
 * @Author: your name
 * @Date: 2021-03-12 20:27:09
 * @LastEditTime: 2021-03-25 13:59:52
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vue-glshaop-client\src\api\index.js
 */
import Ajax from './Ajax'
import mockAjax from './mockAjax'
//三级菜单 get /api/product/getBaseCategoryList
export const CategoryList = () => {
  return Ajax({
    url: '/product/getBaseCategoryList',
    method: 'get'
  })
}
//search页面 post /api/list
export const searchList = (searchParams) => {
  return Ajax({
    url: '/list',
    method: 'post',
    data: searchParams
  })
}
///api/item/{ skuId } get
export const detailPages = (skuId) => {
  return Ajax({
    url: `/item/${skuId}`,
    method: 'get'
  })
}
///api/cart/addToCart/{ skuId }/{ skuNum }
export const addToCart = (skuId, skuNum) => {
  return Ajax({
    url: `/cart/addToCart/${skuId}/${skuNum}`,
    method: 'post'
  })
}
///api/cart/cartList  获取购物车列表 get
export const shopCartList = () => {
  return Ajax({
    url: `/cart/cartList`,
    method: 'get'
  })
}
///api/cart/addToCart/{ skuId }/{ skuNum }  修改购物车的商品数量 post
export const changeShopCartNum = (skuId, skuNum) => {
  return Ajax({
    url: `/cart/addToCart/${skuId}/${skuNum}`,
    method: 'post'
  })
}
///api/cart/checkCart/{skuID}/{isChecked}  修改单个状态
export const isCheckedOne = (skuId, isChecked) => {
  return Ajax({
    url: `/cart/checkCart/${skuId}/${isChecked}`,
    method: 'get'
  })
}
//批量更改购物车选中状态
///api/cart/batchCheckCart/{isChecked}
//post
// isChecked   1或者0                               params参数
// skuIds       要修改的购物车商品的id组成的数组      body参数
export const isCheckedAll = (isChecked, skuIds) => {
  return Ajax({
    url: `/cart/batchCheckCart/${isChecked}`,
    method: 'post',
    data: skuIds
  })
}
///api/cart/deleteCart/{skuId} delete 删除单个
export const deleteOne = (skuId) => {
  return Ajax({
    url: `/cart/deleteCart/${skuId}`,
    method: 'delete'
  })
}

///批量删除购物车
// /api/cart/batchDeleteCart
// delete
//skuIds      要删除的购物车商品的id组成的数组      body参数
export const deleteAll = (skuIds) => {
  return Ajax({
    url: '/cart/batchDeleteCart',
    method: 'delete',
    data: skuIds
  })
}
// /api/user/passport/sendCode/{phone} get 获取验证码
export const getPhoneCode = (phone) => {
  return Ajax({
    url: '/user/passport/sendCode/${phone}',
    method: 'get'
  })
}
//  /api/user/passport/sendCode/{phone} get 
export const register = (phone) => {
  return Ajax({
    url: '/user/passport/sendCode/${phone}',
    method: 'get',
  })
}
// /api/user/passport/login post  登录
export const userLogin = (userInfo) => {
  return Ajax({
    url: '/user/passport/login',
    method: 'post',
    data: userInfo
  })
}
// /user/passport/auth/getUserInfo  get 根据token获取用户数据        /user/passport/auth/getUserInfo
export const userInfos = () => {
  return Ajax({
    url: '/user/passport/auth/getUserInfo',
    method: 'get'
  })
}
///api/user/passport/logout 退出登录 get 
export const loginOut = () => {
  return Ajax({
    url: '/user/passport/logout',
    method: 'get'
  })
}
// /api/order/auth/trade  get 获取订单信息
export const getTradeInfo = () => {
  return Ajax({
    url: '/order/auth/trade',
    method: 'get'
  })
}
// /api/user/userAddress/auth/findUserAddressList  get 获取用户地址
export const userAddress = () => {
  return Ajax({
    url: '/user/userAddress/auth/findUserAddressList',
    method: 'get'
  })
}
// /api/order/auth/submitOrder?tradeNo={tradeNo}   post  提交订单
export const submitOrder = (tradeNo, orderInfo) => {
  return Ajax({
    url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
    method: 'post',
    data: orderInfo
  })
}
// /api/payment/weixin/createNative/{orderId} get  获取订单支付信息
export const getPayInfo = (orderId) => {
  return Ajax({
    url: `/payment/weixin/createNative/${orderId}`,
    method: 'get'
  })
}
// /api/payment/weixin/queryPayStatus/{orderId}    查询订单支付信息
export const getPayCode = (orderId) => {
  return Ajax({
    url: `/payment/weixin/queryPayStatus/${orderId}`,
    method: 'get'
  })
}



export const BannerList = () => {
  return mockAjax({
    url: '/banner',
    method: 'get'
  })
}
export const FloorList = () => {
  return mockAjax({
    url: '/floor',
    method: 'get'
  })
}